<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            var maxArea = function (height) {
                let left = 0
                let right = height.length - 1
                let minHeight = 0
                let res = 0
                while (left < right) {
                    if (height[left] <= height[right]) {
                        minHeight = height[left]
                        res = Math.max(res, minHeight * (right - left))
                        left++
                    } else {
                        minHeight = height[right]
                        res = Math.max(res, (right - left) * minHeight)
                        right--
                    }
                }
                return res
            }
        </script>
    </body>
</html>
